package com.basic.business.controller;

import com.basic.business.common.config.ValidationGroups;
import com.basic.business.model.dto.SysExceptionLogDto;
import com.basic.business.model.vo.SysExceptionLogVo;
import com.basic.business.service.SysExceptionLogService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import com.github.pagehelper.*;

import javax.annotation.Resource;
import javax.validation.constraints.Min;

/**
 * 系统异常日志记录
 *
 * @author huage
 * @since 2021-07-20 14:33:45
 */
@Api(tags = "系统日志记录")
@RestController
@RequestMapping("/sysExceptionLog")
public class SysExceptionLogController {

    @Resource
    private SysExceptionLogService sysExceptionLogService;

    @ApiOperation(value = "通过id查询单条数据 系统异常日志记录")
    @ApiImplicitParam(name = "id", value = "SysExceptionLog id", dataType = "Integer", paramType = "path", required = true)
    @GetMapping("/findById/{id}")
    public SysExceptionLogVo findById(@Min(value = 1) @PathVariable(value = "id") Integer id) {
        return this.sysExceptionLogService.findById(id);
    }

    @ApiOperation(value = "查询多条数据 系统异常日志记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "path", required = true),
            @ApiImplicitParam(name = "pageSize", value = "查询条数", dataType = "int", paramType = "path", required = true)
    })
    @PostMapping(value = "/findPageList/{pageNum}/{pageSize}")
    public PageInfo<SysExceptionLogVo> findPageList(@RequestBody SysExceptionLogDto sysExceptionLogDto, @PathVariable(value = "pageNum") int pageNum, @PathVariable(value = "pageSize") int pageSize) {
        return this.sysExceptionLogService.findPageList(sysExceptionLogDto, pageNum, pageSize);
    }

    @ApiOperation(value = "新增数据 系统异常日志记录")
    @PostMapping("/add")
    public SysExceptionLogVo add(@Validated(ValidationGroups.Save.class) @RequestBody SysExceptionLogDto sysExceptionLogDto) {
        return this.sysExceptionLogService.add(sysExceptionLogDto);
    }

    @ApiOperation(value = "修改数据 系统异常日志记录Dto")
    @ApiImplicitParam(name = "id", value = "SysExceptionLog id", dataType = "long", paramType = "query", required = true)
    @PatchMapping("/modify")
    public SysExceptionLogVo modify(@Validated(ValidationGroups.Update.class) @RequestBody SysExceptionLogDto sysExceptionLogDto) {
        return this.sysExceptionLogService.modify(sysExceptionLogDto);
    }

    @ApiOperation(value = "通过主键删除数据 系统异常日志记录")
    @ApiImplicitParam(name = "id", value = "SysExceptionLog id", dataType = "Integer", paramType = "path", required = true)
    @DeleteMapping("/remove/{id}")
    public boolean remove(@Min(value = 1) @PathVariable(value = "id") Integer id) {
        return this.sysExceptionLogService.remove(id);
    }

}
